package cate.game.attr;

import cate.common.table.item.gem.row.GemBaseRow;
import cate.game.play.support.PlayBuildContext;
import cate.game.role.bag.equip.GemsOn;
import cate.game.role.bag.gem.Gem;
import cate.game.role.bag.hero.Hero;
import org.apache.commons.lang3.StringUtils;


public class GemPowerAttrPart extends PowerAttrPart {
    public GemPowerAttrPart(){}

    public GemPowerAttrPart(PlayBuildContext ctx, GemsOn po, Hero owner) {
        FightAttr attr = new FightAttr();
        if (po != null) {
            for (Gem gem : po.gemMap.values()) {
                GemBaseRow row = gem.getTpl(ctx);
                if (row == null) {
                    continue;
                }
                if (StringUtils.isNotBlank(row.attrStr)) {
                    attr.add(new FightAttr(row.attrStr));
                }

                if (StringUtils.isNotBlank(row.speAttrStr)) {
                    attr.add(new FightAttr(row.speAttrStr));
                }
            }
        }
        this.attr = attr;
        this.powerExt = 0;
        this.skills = po.getSkills(ctx, owner);
    }
}
